package hello;

public class ArrayFunc {
    public static void main(String[] args) {

        //Array
        int[][] arrInt = {{ 1, 2, 3}, { 4, 5, 6}};

        int[][] arrDiff;
        arrDiff = new int[2][];
        arrDiff[0] = new int[3];
        arrDiff[1] = new int[5];
        for (int i = 0; i < arrDiff.length; i++) {
            for (int j = 0; j < arrDiff[i].length; j++) {
                arrDiff[i][j] = i + j;
                System.out.print(arrDiff[i][j] + " ");
            }
            System.out.println();
        }

        // map Array
        String[] strArr = {"str1", "strAnother", "strOthers"};
        for (String str : strArr) {
            System.out.print(str + " ");
        }
        System.out.println();

        // String Pool
        String str1 = "is this string the same";
        String str2 = "is this string the same";
        System.out.printf("str1 == str2 ? %b\r\n", str1 == str2);

        // String Pool is different from String Wrapper Object
        String str3 = new String("is this string the same");
        System.out.printf("string pool? %b\r\n", str1 == str3);
        System.out.printf("String Object Equal? %b\r\n", str3.equals(str1));

        // Flyweight Mode
        String str4 = "Hello ";
        String str5 = "World!";
        String str6 = "Hello World!";
        String str7 = str4 + str5;
        System.out.printf("Before intern(Flyweight Mode): %b\r\n", str6 == str7);
        str7 = str7.intern();
        System.out.printf("After intern(Flyweight Mode): %b\r\n", str6 == str7);
    }
}